package com.dongdongshop.page;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.List;

@Data
@Accessors(chain = true)
public class PageBean<T> implements Serializable {

    private Integer pageNum;
    private Integer pageSize;
    private Long total;
    private List<T> rows;
    private Long allPage;

    public Long getAllPage() {
        return total % pageSize == 0 ? total / pageSize : total / pageSize + 1;
    }


    public PageBean() {
    }

    public PageBean(Integer pageNum, Integer pageSize, Long total, List<T> rows, Long allPage) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.total = total;
        this.rows = rows;
        this.allPage = allPage;
    }
}

